package com.xx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Student;
import com.xx.mapper.StudentMapper;
import com.xx.pojo.po.StudentQueryPo;
import com.xx.service.StudentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 学生 服务实现类
 * </p>
 *
 * @author lotey
 * @since 2023-12-18 21:08
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {

    @Override
    public PageInfo<Student> queryPage(StudentQueryPo po) {
        PageHelper.startPage(po.getPage(), po.getLimit());
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(po.getName())) {
            queryWrapper.like(Student::getName, po.getName());
        }
        List<Student> studentList = list(queryWrapper);
        return new PageInfo<>(studentList);
    }
}
